import { stream, util } from "@kit.ArkTS";
import { PassThrough } from "./passThrough";


/**
 * @internal
 * @param stream - to be split.
 * @returns stream split into two identical streams.
 */
export async function splitStream(streamInput: stream.Readable): Promise<[stream.Readable, stream.Readable]> {
  const stream1 = new PassThrough(streamInput,'split_Stream_1');
  const stream2 = new PassThrough(streamInput,'split_Stream_2');
  streamInput.pipe(stream1);
  streamInput.pipe(stream2);
  return [stream1, stream2];
}

